package com.sfac.springBoot.module.test.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.sfac.springBoot.module.common.entity.AbstractEntity;

import javax.persistence.*;
import java.util.List;

/**
 * personal demo
 **/
@Entity
@Table(name = "test_student")
public class Student extends AbstractEntity {
    private String name;
    private int age;

    @OneToOne(targetEntity = Card.class,cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "card_id",unique = true)
    private Card studentCard;

    public Student() {
    }

    public String getName() {
        return name;
    }


    @ManyToMany(mappedBy = "students",cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JsonIgnore
    private List<Clazz> clazzes;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Card getStudentCard() {
        return studentCard;
    }

    public void setStudentCard(Card studentCard) {
        this.studentCard = studentCard;
    }

    public List<Clazz> getClazzes() {
        return clazzes;
    }

    public void setClazzes(List<Clazz> clazzes) {
        this.clazzes = clazzes;
    }

    public void setName(String name) {
        this.name = name;
    }
}
